HSBC has agreed to pay €40m Swiss francs (£28m) to settle an investigation by prosecutors in Geneva